/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

constexpr int maxn = 2e5 + 2;

int sum[maxn], buc[maxn * 2];

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      int a;
      cin >> a;
      sum[i] = sum[i - 1] ^ a;
    }
    long long ans = 0;
    buc[0] = 1;
    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j * j <= n * 2; ++j) {
        if ((sum[i] ^ (j * j)) <= n * 2) ans += buc[sum[i] ^ (j * j)];
      }
      buc[sum[i]]++;
    }
    for (int i = 1; i <= n; ++i) {
      buc[sum[i]]--;
    }
    cout << (long long)n * (n - 1) / 2 + n - ans << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("C. Even Subarrays.in", "r", stdin);
  freopen("C. Even Subarrays.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
